﻿using CTM.Web.Models.View.Conversation;
using CTM.Web.Models.View.Feedback;
using CTM.Web.Utils;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CTM.Web.Models.View.Report
{
    public class ReportViewModel
    {
        #region Properties

        /// <summary>
        /// The current viewing user
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// The current viewing year
        /// </summary>
        public int Year { get; set; }

        public bool IncludeIndirectEmployees { get; set; }

        /// <summary>
        /// Conversation collection
        /// </summary>
        public IEnumerable<ConversationViewModel> Conversations { get; set; }
        public IList<ReportItemViewModel> ConversationDetails { get; set; }

        public int TotalConversations { get; set; }
        public int TotalFeedbacks { get; set; }
        public Dictionary<Emoticon, int> StatusSummaries { get; set; }
        public Dictionary<PostType, int> ClassificationSummaries { get; set; }

        /// <summary>
        /// Feedback collection
        /// </summary>
        public IEnumerable<FeedbackViewModel> Feedbacks { get; set; }
        public IList<ReportItemViewModel> FeedbackDetails { get; set; }

        public Dictionary<Emoticon, int> FeedbackSummaries { get; set; }

        public List<ChartItem> ChartConversationStatusData { get; set; }
        public List<ChartItem> ChartConversationClassificationData { get; set; }
        public List<ChartItem> ChartFeedbackData { get; set; }

        #endregion

        public ReportViewModel()
        {
            Year = DateTime.Today.Year;

            Conversations = Enumerable.Empty<ConversationViewModel>();
            ConversationDetails = new List<ReportItemViewModel>();
            StatusSummaries = new Dictionary<Emoticon, int>();
            ClassificationSummaries = new Dictionary<PostType, int>();

            Feedbacks = Enumerable.Empty<FeedbackViewModel>();
            FeedbackDetails = new List<ReportItemViewModel>();
            FeedbackSummaries = new Dictionary<Emoticon, int>();

            ChartConversationStatusData = new List<ChartItem>();
            ChartConversationClassificationData = new List<ChartItem>();
            ChartFeedbackData = new List<ChartItem>();
        }
    }

    public class ReportSearchModel
    {
        public int? Year { get; set; }
        public string Keyword { get; set; }
        public List<Emoticon> Statuses { get; set; }
        public List<PostType> Types { get; set; }
        public List<Guid> Orgs { get; set; }

        public bool IncludeIndirectEmployees { get; set; }
        public int? PageSize { get; set; }

        public ReportSearchModel()
        {
            Year = DateTime.Today.Year;
            Statuses = new List<Emoticon>();
            Types = new List<PostType>();
            Orgs = new List<Guid>();
            PageSize = 10;
        }
    }

    public class TreeNode
    {
        public Guid id { get; set; }
        public string text { get; set; }
        public Guid? parentId { get; set; }
        public List<TreeNode> nodes { get; set; }
    }

    public class ChartItem
    {
        public string label { get; set; }
        public int value { get; set; }
    }

    public class ReportItemViewModel
    {
        public string Associate { get; set; }
        public string AssociateId { get; set; }
        public int NoMyPost { get; set; }
        public int NoOtherPost { get; set; }

        public int NoSmilePost { get; set; }
        public int NoNeutralPost { get; set; }
        public int NoFrownPost { get; set; }

        public int NoGoalsPost { get; set; }
        public int NoCareerPost { get; set; }
        public int NoIndividualPost { get; set; }
    }
}